package com.cmfi.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.cmfi.domain.ReadMe;

// TODO 添加@Mapper
@Mapper
public interface ReadMeDao {
    @Insert("insert into tbl_readme (roleId,path) values(#{roleId},#{path})")
    public int save(ReadMe readMe);
    
    @Update("update tbl_readme set roleId = #{roleId}, path = #{path} where id = #{id}")
    public int update(ReadMe readMe);
    
    @Delete("delete from tbl_readme where id = #{id}")
    public int delete(Long id);
    
    @Select("select * from tbl_readme where id = #{id}")
    public ReadMe getById(Long id);
    
    @Select("select count(1) from tbl_readme")
	Long count();
    
    @Select("select * from  tbl_readme order by id DESC limit #{start},#{itemNum}")
	List<ReadMe> findByPage(long start, long itemNum);
    
    @Select("select * from  tbl_readme where id=#{id}")
    ReadMe findById(Long id);
    
    @Select("select tbl_user_role.roleId from tbl_user join tbl_user_role on tbl_user.id=tbl_user_role.userId where tbl_user.id = #{id}")
    public long findRoleId(Long id);
    
    @Select("select tbl_readme.path from tbl_readme where tbl_readme.roleId = #{roleId}")
	List<ReadMe> findByUser(long roleId);

    @Select("select * from  tbl_readme order by id DESC")
	public List<ReadMe> findAllReadMes();
}
